//请求图片
const xhr = new XMLHttpRequest();

self.onmessage = (e) => {
    xhr.open('get', '/get_pic?classN=' + e.data, true);
    xhr.send();
    xhr.onreadystatechange = () => {
        if (xhr.readyState === 4 && xhr.status === 200) {
            if (xhr.responseText === 'no') {
                alert('获取失败！');
                return;
            }
            let objDate = JSON.parse(xhr.responseText);
            let temp = '';
            for (let i = 0; i < objDate.infoArr.length; i++) {
                if (objDate.infoArr[i].name !== '') {
                    temp += `<div class="img_list">
                    <p class="update">上传时间：${objDate.infoArr[i].update}</p>
                    <p class="name">分类：${objDate.infoArr[i].class}</p>
                    <img class="imgs" data-class="${objDate.infoArr[i].class}" data-name="${objDate.infoArr[i].name}" src="" data-src-url="${objDate.infoArr[i].imgUrl}" alt="">
                    <button class="del" data-class="${objDate.infoArr[i].class}" data-name="${objDate.infoArr[i].name}">删 除</button>
                   </div>`;
                }
            }
            self.postMessage(temp);
        }
    }
}